#include "error.h"
#include "la.h"
#include "global.h"

char reset_char[] = ",;(){}\n";

void print_error(char *err_msg, char *ref_msg, char *skp_str)
{
    if (ERRORED == FALSE) {
        ERRORED = TRUE;
    }
    if (QUIET == TRUE)
        return;
    fprintf(error, "Error %d, at row %d, column %d: %s\n", error_count, row, col, err_msg);
    if (strcmp(ref_msg, "")) {
        fprintf(error, "\tExtra Info: \'%s\'\n", ref_msg);
    }
    error_count++;
    if (skp_str != NULL) {
        skip(skp_str);
    }
}

void print_warning(char *warn_msg, char *ref_msg)
{
    if (ERRORED == FALSE) {
        ERRORED = TRUE;
    }
    if (QUIET == TRUE)
        return;
    fprintf(error, "Warning %d, at row %d, column %d: %s\n", warning_count, row, col, warn_msg);
    if (strcmp(ref_msg, "")) {
        fprintf(error, "\tExtra Info: \'%s\'\n", ref_msg);
    }
    warning_count++;
}


void print_fatal()
{
    fprintf(error, "Error %d, at row %d, column %d: Fatal error. Program gonna be closed.\n", error_count, row, col);
    error_count++;
    exit(1);
}
